<template>
	<view>
		<van-steps direction="vertical" :active="count" >
			<van-step v-for="item in datatabel" @click="yanshou(item)">
				<h3>{{item.ProcedureName}}</h3>
				<p>开始时间：{{data(item.BeginDate)}}</p>
				<p>结束时间：{{data(item.EndDate)}}</p>
			</van-step>
		</van-steps>
	</view>
</template>

<script setup>
	import {
		ref,
		onMounted,
		getCurrentInstance
	} from 'vue';
	import userprocedureapi from '../../api/userprocedureapi';
	import userprocedureRecordApi from '../../api/userprocedureRecordApi';
	const props = defineProps({
		navigator: Object
	});
	const datatabel = ref([])
	const datarecord = ref([])
	const count = ref()
	userprocedureapi.getByProject(props.id).then(res=>{
		console.log(res)
		datatabel.value = res.data.sort((a,b)=>a.ProcedureOrder-b.ProcedureOrder)
		count.value = res.data.filter(o=>o.Status==2).length-1;
	})
	onMounted(() => {
		console.log(props.id)
	})
	const data = (param)=> {
	  if(!param) return ""
	
	const date = new Date(param)
	  const year = date.getFullYear();
	  const month = String(date.getMonth() + 1).padStart(2, '0');
	  const day = String(date.getDate()).padStart(2, '0');
	
	  return `${year}-${month}-${day}`;
	}
	
	userprocedureRecordApi.getAll({}).then(res=>{
		console.log("2",res)
		datarecord.value = res.data.length
	}) 
	const yanshou=(item)=>{
		uni.navigateTo({
			url:"../MyProject/Acceptance?item="+JSON.stringify(item)
		});
	}
</script>

<style scoped>
</style>